#include <string.h>

#include "sha1.hpp"

namespace crypto
{
	Sha1::Sha1()
	{
		memset(&_ctx, 0, sizeof(_ctx));
	}

	void Sha1::start()
	{
		memset(&_ctx, 0, sizeof(_ctx));

		sha1_init_ctx(&_ctx);
	}

	void Sha1::process(const void * buffer, size_t len)
	{
		sha1_process_bytes(buffer, len, &_ctx);
	}

	void Sha1::finish(std::string & resstr)
	{
		uint32_t resbuf[5];

		sha1_finish_ctx(&_ctx, (void*)resbuf);

		resstr.assign((char*)resbuf, sizeof(resbuf));
	}
};

